home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 7 / Apprentice-Release7.iso / Source Code / PowerPlant / CExep / CExeption.cp < prev    next >
Encoding:
Text File  |  1997-01-22  |  2.8 KB  |  93 lines  |  [TEXT/CWIE]

  1. // ===========================================================================
  2. // CExeption.cp           ©1996 Sunbay Development Group. All rights reserved.
  3. // ===========================================================================
  4. // Jul 17,1996
  5.  
  6. #include <Memory.h>
  7. #include <Menus.h>
  8. #include "CExeption.h"
  9.  
  10. Str255    CExeption::mDescriptor;
  11.  
  12. // ---------------------------------------------------------------------------
  13. // Constructor
  14. // ---------------------------------------------------------------------------
  15.  
  16. CExeption::CExeption(void) {
  17.     mType = 0;
  18.     mCode = 0;
  19.     mDescriptor[0] = 0;
  20. }
  21.  
  22. // ---------------------------------------------------------------------------
  23. // Destructor
  24. // ---------------------------------------------------------------------------
  25.  
  26. CExeption::~CExeption(void) {
  27. }
  28.  
  29. // ---------------------------------------------------------------------------
  30. // Process exeption
  31. // ---------------------------------------------------------------------------
  32.  
  33. Boolean CExeption::Process(void) {
  34.     Boolean    expProcessed = false;
  35.     return expProcessed;
  36. }
  37.  
  38. // ---------------------------------------------------------------------------
  39. // Create alert
  40. // ---------------------------------------------------------------------------
  41. // The dialog box has to have one button that generate message cmd_Close (4)
  42.  
  43. void CExeption::Alert(OSType inResID) {
  44.     LDialogBox *        dlog;
  45.     LCommander *        superCommander;
  46.     LEventDispatcher *    evtDispetcher;
  47.     EventRecord         macEvent;
  48.     Boolean             gotEvent;
  49.     LMenuBar *            theMenuBar;
  50.     LMenu *                theMenu;
  51.  
  52.     evtDispetcher = LEventDispatcher::GetCurrentEventDispatcher();
  53.     superCommander = LCommander::GetTopCommander();
  54.     LCommander::SetDefaultCommander(superCommander);
  55.     dlog = (LDialogBox *) UReanimator::ReadObjects('PPob', inResID);
  56.     if(dlog != nil) {
  57.         dlog->FinishCreate();
  58.         CastomAlert(dlog);
  59.         UDesktop::Deactivate();
  60.         //        Disable menu bar
  61.         theMenuBar = LMenuBar::GetCurrentMenuBar();
  62.         if(theMenuBar != nil) {
  63.             theMenu = nil;
  64.             while(theMenuBar->FindNextMenu(theMenu)) {
  65.                 ::DisableItem(theMenu->GetMacMenuH(), 0);
  66.             }
  67.         }
  68.         dlog->Show();
  69.         //        Event loop of the dialog
  70.         do {
  71.             gotEvent = ::WaitNextEvent(everyEvent, &macEvent, 6, dlog->GetLocalUpdateRgn());
  72.             if(evtDispetcher->ExecuteAttachments(msg_Event, &macEvent)) {
  73.                 if(gotEvent) evtDispetcher->DispatchEvent(macEvent);
  74.                 else evtDispetcher->UseIdleTime(macEvent);
  75.             }
  76.             //        Repeaters get time after every event
  77.             LPeriodical::DevoteTimeToRepeaters(macEvent);
  78.         } while(UDesktop::FetchTopModal() == dlog);
  79.         //        Enable menu bar
  80.         if(theMenuBar != nil) {
  81.             theMenu = nil;
  82.             while(theMenuBar->FindNextMenu(theMenu)) {
  83.                 ::EnableItem(theMenu->GetMacMenuH(), 0);
  84.             }
  85.         }
  86.         //        Update status of menu items
  87.         if(dlog->IsOnDuty() && dlog->GetUpdateCommandStatus())
  88.             evtDispetcher->UpdateMenus();
  89.         UDesktop::Activate();
  90.     }
  91. }
  92.  
  93.